home *** CD-ROM | disk | FTP | other *** search
/ Leonardo the Inventor / Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso / LEOWINMV / DATABASE.DIR / 00106_Script_CHECK DATABASE - LINKS < prev    next >
Text File  |  1996-03-28  |  3KB  |  91 lines

  1. -- --------------------------------------------------------------
  2. -- Handler getLinks finds all the hypertext links in the given
  3. -- casts and stores them in the field "hyperText links"
  4.  
  5. on getLinks firstCast, lastCast, linkStyle, linkColor
  6.   -- empty the field for the new generation
  7.   put EMPTY into field "hyperText Links"
  8.   
  9.   -- go through every cast from firstCast to lastCast
  10.   repeat with currentCast = firstCast to lastCast
  11.     set curArticle = the name of cast currentCast
  12.     
  13.     put "checking links in cast" && currentCast && "," && curArticle
  14.     
  15.     set numWords = the number of words in field currentCast
  16.     set curWordNum = 1
  17.     
  18.     -- go through every word in the current cast.
  19.     repeat while (curWordNum <= numWords)
  20.       -- get the style and color of the current word
  21.       set curWord = word curWordNum of field currentCast
  22.       set curStyle = the textStyle of word curWordNum of field currentCast
  23.       set curColor = the foreColor of word curWordNum of field currentCast
  24.       set hyperphrase = EMPTY
  25.       
  26.       -- if the current word is part of a hypertext phrase, the following
  27.       -- repeat loop will be executed.
  28.       repeat while (curColor = linkColor) and (curStyle = linkStyle) then
  29.         -- found a hypertext word
  30.         -- get the whole hypertext phrase, and update curWordNum
  31.         put "found a hypertext link in cast" && currentCast && "," && curArticle
  32.         
  33.         set hyperphrase = hyperphrase & word curWordNum of field currentCast
  34.         set curWordNum = curWordNum + 1
  35.         
  36.         -- get the style and color of the next word
  37.         set curStyle = the textStyle of word curWordNum of field currentCast
  38.         set curColor = the foreColor of word curWordNum of field currentCast
  39.       end repeat -- end of hypertext phrase reached
  40.       
  41.       if (hyperphrase <> EMPTY) then
  42.         put curArticle & ":" & hyperphrase & RETURN after field "hyperText Links"
  43.       end if
  44.       
  45.       set curWordNum = curWordNum + 1
  46.     end repeat -- going through all words in cast currentCast
  47.     
  48.   end repeat -- going through all casts
  49. end
  50.  
  51. -- --------------------------------------------------------------
  52. -- Handler checkLinks checks all the links in field "hyperText links"
  53.  
  54. on checkLinks
  55.   -- empty the field for the new generation
  56.   put EMPTY into field "hyperText Errors"
  57.   
  58.   initalizeEquivalentTerms
  59.   
  60.   set linkInfo = field "hyperText Links"
  61.   set numLinks = the number of lines in linkInfo
  62.   
  63.   -- go through all the links
  64.   repeat with i = 1 to numLinks
  65.     put "checking" && i && "of" && numlinks
  66.     -- keep setting the itemDelimiter because it is reset in getEquivalentTerm
  67.     set the itemDelimiter = ":"
  68.     
  69.     set originalCast = item 1 of line i of linkInfo
  70.     set curLink = item 2 of line i of linkInfo
  71.     
  72.     -- check if the phrase ends with punctuation
  73.     repeat while(endsWithPunctuation(curLink))
  74.       set curLink = removePunctuationFromEnd(curLink) 
  75.     end repeat
  76.     
  77.     -- go through the current link
  78.     set linkCast = the number of cast (curLink && "TEXT1")
  79.     
  80.     if (linkCast = -1) then
  81.       -- check if an equivalent term exists
  82.       set equivTerm = getEquivalentTerm(curLink)
  83.       if (equivTerm = -1) then
  84.         -- hypertext error
  85.         put originalCast & ":" & curLink & RETURN after field "hyperText Errors"
  86.       end if
  87.     end if
  88.   end repeat
  89.   
  90.   set the itemDelimiter = ","
  91. end